#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
   @Author: 叶建伟
   @Email: yejw46507@hundsun.com
   @Time: 2023/7/4 14:50
   @File: clientInfo.py
"""
import datetime
from random import choice

from faker import Faker

from DataTest.tabledata.commonData import randomInfo

bank_list = {''}
#'50'基金成立,'51',基金终止
bussine_flag_list = ['01','02','03','04','05','06','07','10','11','12','13','17','81','82','83','84','85','86','87','88','89']
#学历：'01'博士 ,'02'硕士,'03'学士,'04'大专,'05'中专,'06'高中,'07'高中及以下,'99'其他
education_code_list = ['01','02','03','04','05','06','07','99']
#职业代码 37学生 99其他
occupation_code_list = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','99']
#130 成立，122 申购，124 赎回，131 理财份数冻结，132 理财份数解冻，134 非交易过户转入，135 非交易过户转出，198 快速过户，151 产品终止，142 强行赎回
c_businflag_list = ['130','122','124','131','132','134','135','198','151','142']
#银行理财产品
c_fundcode_list = ['SGQ419','010922','010142','008470','008469','007881','SVP081','SQQ856','007494','007880','007881','010141']
#银行产品性质
c_raisetype_list = ['1100','1200','1300','1301','1302','1401','1407']

def client_info():
    '''
    利用fake工具生成个人信息
    '''
    client_list = {}
    fake = Faker(locale='zh_CN')
    client_name = fake.name() #姓名
    c_client_name = client_full_name = client_name #全名
    daytime_client_name = fake.name() #日间客户名称
    contact_address = fake.address().split(' ')[0] #联系地址
    c_address = contact_address #投顾客户联系地址
    birth_date = fake.date(pattern = '%Y%m%d')#生日
    email_address = fake.email()#邮箱
    id_no = fake.ssn() #身份证
    c_id_no = id_no #投顾身份证
    daytime_id_no = fake.ssn() #日间客户身份证
    telephone_number = fake.phone_number()  #电话号码
    c_mobile_tel = telephone_number
    cellphone_number = fake.phone_number()  #移动电话号码
    nationality_code = fake.country_code()  #国籍代码
    occupation_code = choice(occupation_code_list)  #职业代码
    c_profession_code = occupation_code #投顾客户职业代码
    # industry_code =  #行业代码
    education_code = choice(education_code_list)
    business_flag = choice(['01','02','03']) #业务标识'01'认购,'02'申购,'03'赎回
    work_unit = fake.company() #工作单位
    work_unit_tel = fake.phone_number() #工作单位电话
    work_unit_address = fake.address().split(' ')[0] #工作单位地址
    addr_zip = fake.address().split(' ')
    resident_address = addr_zip[0]  #居住地址
    zip_code = addr_zip[1]  #邮政编码
    occur_date = fake.date_between(start_date='-1y', end_date='today').strftime("%Y%m%d") #发生日期
    fund_account = 'hsjj'+str(fake.random_number(digits=8))+str(fake.random_number(digits=6)) #基金账户
    fund_acc_status = '0' # 基金账户状态
    trade_status = '1' # 交易状态
    trade_account = 'jyzh'+str(fake.random_number(digits=8))+str(fake.random_number(digits=6))  # 交易账户
    apply_date = fake.date_between(start_date='-1d', end_date='today').strftime("%Y%m%d") #申请日期
    id_end_date = fake.date_between(start_date='-3m', end_date='+36y').strftime("%Y%m%d") #证件有效期
    c_corp_end_date = id_end_date #投顾客户证件有效期
    apply_no = 'sq'+str(fake.random_number(digits=8))+str(fake.random_number(digits=6)) #账号申请编号
    c_comb_request_no = apply_no #组合申请编号
    c_orig_comb_request_no = apply_no #组合申请编号
    c_comb_fare_request_no = apply_no #组合申请编号
    confirm_no ='qrbh'+str(fake.random_number(digits=8))+str(fake.random_number(digits=6))   #账号确认编号
    confirm_date = fake.date_between(start_date='-1y', end_date='today').strftime("%Y%m%d")  #账号确认时间
    serial_no = fake.uuid4()[:-4]  #序列号
    c_agreement_id = serial_no
    l_serial_no = str(fake.random_number(digits=18))
    uuid_code = fake.uuid4()[:-4]#通用唯一识别码
    c_position_str = uuid_code #定位串
    open_bank_name = fake.credit_card_provider(card_type=None)  #开户银行名称
    bank_account = fake.credit_card_number(card_type=None)  #银行卡号

    # C_TRANS_ACCOUNT  = 'TG'+str(fake.random_number(digits=8)) #客户ID
    c_investor_account = 'TG'+str(fake.random_number(digits=8)) #投顾账户ID
    c_trans_account = str(fake.random_number(digits=12)) #投顾交易账户
    c_asset_unit = str(fake.random_number(digits=6)) #资产单元
    l_curr_date = fake.date_between(start_date='-1m', end_date='today').strftime("%Y%m%d") #签约日期
    c_prod_code = choice(['08172','08174','08178']) #产品代码
    c_prodta_no = 'TG'
    c_merchant_no = choice(['1002','1003','1011']) #商户号
    c_combine_code = choice(['T08172','T08174','T08178']) #组合代码
    c_business_flag = choice(['39120','39122','39124','39144','39145']) #组合业务类型
    c_money_type = choice(['1','2','0']) #交易币种
    c_gender = choice(['1','2']) #性别
    l_corp_risk_level = choice(['1','2','0']) #客户风险等级

    client_list.update({'c_business_flag': c_business_flag})
    client_list.update({'c_money_type': c_money_type})
    client_list.update({'c_orig_comb_request_no': c_orig_comb_request_no})
    client_list.update({'c_comb_fare_request_no': c_comb_fare_request_no})
    # client_list.update({'client_tgaccoid': client_tgaccoid})
    client_list.update({'c_gender': c_gender})
    client_list.update({'l_corp_risk_level': l_corp_risk_level})

    client_list.update({'c_merchant_no': c_merchant_no})
    client_list.update({'c_combine_code': c_combine_code})
    client_list.update({'c_prodta_no': c_prodta_no})
    client_list.update({'c_comb_request_no': c_comb_request_no})
    client_list.update({'c_agreement_id': c_agreement_id})
    client_list.update({'l_serial_no': l_serial_no})
    client_list.update({'c_position_str': c_position_str})
    client_list.update({'l_curr_date': l_curr_date})
    client_list.update({'c_prod_code': c_prod_code})
    client_list.update({'c_investor_account': c_investor_account})
    client_list.update({'c_client_name': c_client_name})
    client_list.update({'c_id_no': c_id_no})
    client_list.update({'c_address': c_address})
    client_list.update({'c_corp_end_date': c_corp_end_date})
    client_list.update({'c_mobile_tel': c_mobile_tel})
    client_list.update({'c_profession_code': c_profession_code})
    client_list.update({'c_trans_account': c_trans_account})
    client_list.update({'c_asset_unit': c_asset_unit})
    client_list.update({'c_agreement_id': c_agreement_id})


    client_list.update({'daytime_client_name': daytime_client_name})
    client_list.update({'daytime_id_no': daytime_id_no})
    client_list.update({'client_name':client_name})
    client_list.update({'client_full_name':client_full_name})
    client_list.update({'contact_address':contact_address})
    client_list.update({'birth_date':birth_date})
    client_list.update({'email_address':email_address})
    client_list.update({'id_no':id_no})
    client_list.update({'id_end_date':id_end_date})
    client_list.update({'nationality_code':nationality_code})
    client_list.update({'zip_code':zip_code})
    client_list.update({'telephone_number':telephone_number})
    client_list.update({'cellphone_number':cellphone_number})
    client_list.update({'work_unit':work_unit})
    client_list.update({'work_unit_tel':work_unit_tel})
    client_list.update({'work_unit_address':work_unit_address})
    client_list.update({'resident_address':resident_address})
    client_list.update({'email_address':email_address})
    client_list.update({'occur_date':occur_date})
    client_list.update({'apply_date':apply_date})
    client_list.update({'fund_account':fund_account})
    client_list.update({'open_bank_name':open_bank_name})
    client_list.update({'bank_account':bank_account})
    client_list.update({'business_flag':business_flag})
    client_list.update({'fund_acc_status':fund_acc_status})
    client_list.update({'trade_status':trade_status})
    client_list.update({'education_code':education_code})
    client_list.update({'occupation_code':occupation_code})
    client_list.update({'trade_account':trade_account})
    client_list.update({'apply_no':apply_no})
    client_list.update({'confirm_no': confirm_no})
    client_list.update({'confirm_date': confirm_date})
    client_list.update({'serial_no': serial_no})
    client_list.update({'uuid_code': uuid_code})
    # print(client_list)
    return client_list

def client_info_list():
    client_list = {}
    client_list.update(randomInfo.generate_info())
    contact_address = randomInfo.get_address().split(' ')[0] #联系地址
    occupation_code = choice(occupation_code_list)  #职业代码
    nationality_code = 'CHN'  # 国籍代码
    # industry_code =  #行业代码
    education_code = choice(education_code_list) #学历
    business_flag = choice(['01','02','03']) #业务标识'01'认购,'02'申购,'03'赎回
    work_unit = randomInfo.get_company() #工作单位
    work_unit_tel = randomInfo.get_random_cell_phone() #工作单位电话
    work_unit_address = randomInfo.get_address().split(' ')[0] #工作单位地址
    addr_zip = randomInfo.get_address().split(' ')
    resident_address = addr_zip[0]  #居住地址
    zip_code = addr_zip[1]  #邮政编码
    occur_date = randomInfo.get_random_date() #发生日期
    fund_account = 'hsjj'+str(randomInfo.get_random_number(8))+str(randomInfo.get_random_number(6)) #基金账户
    fund_acc_status = '0' # 基金账户状态
    trade_status = '0' # 交易状态
    trade_account = 'hsjy'+str(randomInfo.get_random_number(8))+str(randomInfo.get_random_number(6))  # 交易账户
    apply_date = randomInfo.get_random_date() #申请日期


    # apply_no = fake.date_between(start_date='-2y', end_date='today').strftime("%Y%m%d") #账号申请编号
    # confirm_no =   #账号确认编号
    # comfirm_date =   #账号确认时间
    # serial_no = fake  #序列号
    # uuid_code = fake.uuid4()#通用唯一识别码
    # open_bank_name = fake.credit_card_provider(card_type=None)  #开户银行名称
    # bank_account = fake.credit_card_number(card_type=None)  #银行卡号
    # client_list.update({'client_name':client_name})
    # client_list.update({'client_full_name':client_full_name})
    client_list.update({'contact_address':contact_address})
    client_list.update({'nationality_code':nationality_code})
    client_list.update({'zip_code':zip_code})
    client_list.update({'work_unit':work_unit})
    client_list.update({'work_unit_tel':work_unit_tel})
    client_list.update({'work_unit_address':work_unit_address})
    client_list.update({'resident_address':resident_address})
    client_list.update({'occur_date':occur_date})
    client_list.update({'apply_date':apply_date})
    client_list.update({'fund_account':fund_account})
    client_list.update({'business_flag':business_flag})
    client_list.update({'fund_acc_status':fund_acc_status})
    client_list.update({'trade_status':trade_status})
    client_list.update({'education_code':education_code})
    client_list.update({'occupation_code':occupation_code})
    client_list.update({'trade_account':trade_account})
    # client_list.update({'open_bank_name':open_bank_name})
    # client_list.update({'bank_account':bank_account})
    # client_list.update({'uuid_code':uuid_code})
    # print(client_list)
    return client_list

def client_info_hsraw():
    client_list = {}
    client_list.update(randomInfo.generate_info_raw())
    #hsraw层，BTA接口
    c_fundacco = str(randomInfo.get_random_number(12)) #理财账户
    c_custtype = '1'
    c_identitytype = '0'
    c_accostatus = 'N'
    c_requestno = str(randomInfo.get_random_number(8))+str(randomInfo.get_random_number(8))
    c_outbusinflag = '101'
    c_address = randomInfo.get_address().split(' ')[0] #通讯地址
    addr_zip = randomInfo.get_address().split(' ')
    c_zipcode = addr_zip[1]  #邮政编码
    c_tradeacco = str(randomInfo.get_random_number(14)) # 交易账户
    bankinfo = randomInfo.get_bank().split(' ')
    c_bankname = bankinfo[0]  # 开户银行名称
    c_bankno = bankinfo[1]  # 开户银行简称
    c_bankacco = '622' + str(randomInfo.get_random_number(12))  # 银行卡号
    d_requestdate =  randomInfo.get_random_date(20230102,20240717) #申请日期
    d_cdate = d_requestdate
    d_date = d_requestdate
    d_regdate = d_requestdate
    agencyinfo = randomInfo.get_agency().split(' ')
    c_agencyno = agencyinfo[0] #销售商编号
    c_agencyname = agencyinfo[1]#销售商名称
    c_agencytype = agencyinfo[2]#销售商类型

    client_list.update({'c_fundacco':c_fundacco})
    client_list.update({'c_custtype':c_custtype})
    client_list.update({'c_identitytype':c_identitytype})
    client_list.update({'c_accostatus':c_accostatus})
    client_list.update({'c_requestno':c_requestno})
    client_list.update({'c_outbusinflag':c_outbusinflag})
    client_list.update({'c_address':c_address})
    client_list.update({'c_zipcode':c_zipcode})
    client_list.update({'c_tradeacco':c_tradeacco})
    client_list.update({'c_bankname':c_bankname})
    client_list.update({'c_bankno':c_bankno})
    client_list.update({'c_bankacco': c_bankacco})
    client_list.update({'d_requestdate':d_requestdate})
    client_list.update({'d_cdate':d_cdate})
    client_list.update({'d_date':d_date})
    client_list.update({'d_regdate':d_regdate})
    client_list.update({'c_agencyno':c_agencyno})
    client_list.update({'c_agencyname':c_agencyname})
    client_list.update({'c_agencytype':c_agencytype})
    # print(client_list)

    # client_list = {}
    # client_list.update(randomInfo.generate_info_raw())
    #hsraw层，BTA接口
    c_status = choice(['0','1','8','9']) #产品状态
    c_requestno = 'sq'+str(randomInfo.get_random_number(8))+str(randomInfo.get_random_number(8))
    c_outbusinflag = choice(['101','103'])
    c_sharetype = choice(['A','B'])
    c_othershare = c_sharetype
    c_businflag = choice(c_businflag_list)
    c_moneytype = '156'
    c_udid = str(randomInfo.get_random_number(24))#通用唯一识别码
    bankinfo = randomInfo.get_bank().split(' ')
    c_bankname = bankinfo[0]  #开户银行名称
    c_bankno = bankinfo[1]  #开户银行简称
    c_bankacco = '622' + str(randomInfo.get_random_number(12))  #银行卡号
    d_requestdate =  randomInfo.get_random_date(20230102,20240717) #申请日期
    d_cdate = d_requestdate
    d_date = d_requestdate
    d_regdate = d_requestdate
    d_datadate = d_requestdate
    c_cserialno = str(randomInfo.get_random_number(8))+str(randomInfo.get_random_number(8))
    f_balance = randomInfo.get_random_number(6)
    f_confirmbalance = f_balance
    f_netvalue = 1.25
    f_confirmshares = f_confirmbalance / f_netvalue
    c_bonustype = '1'
    agencyinfo = randomInfo.get_agency().split(' ')
    c_agencyno = agencyinfo[0] #销售商编号
    c_agencyname = agencyinfo[1]#销售商名称
    c_agencytype = agencyinfo[2]#销售商类型
    proinfo = randomInfo.get_pro().split(' ')
    c_fundcode = proinfo[0] #产品编号
    c_fundname = proinfo[1]#产品名称
    c_property = proinfo[2]#产品性质

    client_list.update({'c_status':c_status})
    client_list.update({'c_requestno':c_requestno})
    client_list.update({'c_outbusinflag':c_outbusinflag})
    client_list.update({'c_sharetype':c_sharetype})
    client_list.update({'c_othershare':c_othershare})
    client_list.update({'c_businflag':c_businflag})
    client_list.update({'c_moneytype':c_moneytype})
    client_list.update({'c_udid':c_udid})
    client_list.update({'c_bankname':c_bankname})
    client_list.update({'c_bankacco':c_bankacco})
    client_list.update({'c_bankno': c_bankno})
    client_list.update({'d_requestdate':d_requestdate})
    client_list.update({'d_cdate':d_cdate})
    client_list.update({'d_date':d_date})
    client_list.update({'d_regdate':d_regdate})
    client_list.update({'d_datadate':d_datadate})
    client_list.update({'c_cserialno':c_cserialno})
    client_list.update({'f_balance':f_balance})
    client_list.update({'f_confirmbalance':f_confirmbalance})
    client_list.update({'f_netvalue':f_netvalue})
    client_list.update({'f_confirmshares':f_confirmshares})
    client_list.update({'c_bonustype':c_bonustype})
    client_list.update({'c_agencyno':c_agencyno})
    client_list.update({'c_agencyname':c_agencyname})
    client_list.update({'c_agencytype':c_agencytype})
    client_list.update({'c_fundcode':c_fundcode})
    client_list.update({'c_fundname': c_fundname})
    client_list.update({'c_property': c_property})
    # print(client_list)
    return client_list




if __name__ == '__main__':
    # for i in range(0,10):
    #     client_info()
    #     print(datetime.datetime.now())

    print(datetime.datetime.now())
    # list = []
    # fake = Faker(locale='zh_CN')
    for i in range(100000):
        client_info_hsraw()
    print(datetime.datetime.now())
    # print(list)
    # print(len(list))
